package com.infoland.afanmall.model.my.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;

import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.infoland.afanmall.R;
import com.infoland.afanmall.base.util.LogKit;
import com.infoland.afanmall.base.util.StatusBarKit;
import com.infoland.afanmall.base.util.ToolsKit;
import com.infoland.afanmall.model.my.fragment.HdFragment;
import com.infoland.afanmall.model.my.fragment.WlFragment;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 个人中心消息展示
 */

public class MsgActivity extends AppCompatActivity {

    @BindView(R.id.zhong_chou_tab)
    SlidingTabLayout msgTab;
    @BindView(R.id.zhong_chou_page)
    ViewPager msgViewPage;
    @BindView(R.id.title_layout)
    LinearLayout titleLayout;
    private ArrayList<Fragment> mFragments = new ArrayList<>();
    private String[] mTitles = {"活动信息", "物流信息"};

    private int getLayout() {
        return R.layout.msg_activity;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayout());
        ButterKnife.bind(this);
        StatusBarKit.immersiveBlackTitleText(this, titleLayout);
        initData();
    }

    private void initData() {
        mFragments.add(new HdFragment());
        mFragments.add(new WlFragment());
        msgTab.setViewPager(msgViewPage, mTitles, this, mFragments);
        msgViewPage.setCurrentItem(0);
        msgViewPage.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                LogKit.E("  onPageSelected ", "  " + position);

            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
        msgTab.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                LogKit.E("  onTabSelect ", "  " + position);
            }

            @Override
            public void onTabReselect(int position) {
                LogKit.E("  onTabReselect ", "  " + position);

            }

        });
    }


    @OnClick({R.id.back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
        }
    }
    @Override
    protected void onDestroy() {
        ToolsKit.deleteOKHttp(this);
        super.onDestroy();
    }
}
